import BaseItemView from "../../../cfw/mvc/BaseItemView";
import GameItemModel from "../../base/GameItemModel";
import ModuleManager from "../../../cfw/module/ModuleManager";
import { ResType } from "../../../cfw/res/ResInterface";
import ResItem from "../../../cfw/res/ResItem";


const { ccclass, property } = cc._decorator;

@ccclass
export default class BigExportPage3Item extends BaseItemView {

	@property({ type: cc.Label, displayName: "gameName$VLabel" })
	gameName$VLabel: cc.Label = null;

	@property({ type: cc.Sprite, displayName: "gameIcon$VSprite" })
	gameIcon$VSprite: cc.Sprite = null;





	protected model: GameItemModel

	onLoad() {
	}

	refresh() {
		if (this.model) {
			this.gameName$VLabel.string = this.model.getGameName()
			// console.log(' this.model.getGameIcon() ', this.model.getGameIcon())
			ModuleManager.publicLoader().loadRes(this.model.getGameIcon(), ResType.Remote, (err, res: ResItem) => {
				if (err || !cc.isValid(this.node)) {
					return;
				}
				this.gameIcon$VSprite.spriteFrame = new cc.SpriteFrame(res.getRes())
			})
		} else {
			this.clear()
		}

	}

	clear() {
		this.gameIcon$VSprite.spriteFrame = null;
		this.gameName$VLabel.string = ''
	}


	onButtonClick() {
		if (this.controller && this.model)
			this.controller.clickPage3Game(this.model)
	}



}